package restful_apis.zzz_search;

import backend.service.search.SemanticFulltextSearchService;
import org.springframework.stereotype.Component;
import restful_apis.common.MediaTypes;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

/**
 * Created by julianzliu on 4/25/2017.
 */


@Path("/search")
@Produces(MediaTypes.JSON_UTF8)
@Component
public class SearchRestAPI {


    private SemanticFulltextSearchService searchService;

    @Inject
    public SearchRestAPI(SemanticFulltextSearchService searchService){
        this.searchService = searchService;
    }


    @GET
    @Path("/_search")
    @Produces(MediaTypes.JSON_UTF8)
    public String search(
            @QueryParam("q") String q
    ){
        return this.searchService.searchJsonResult( q );
    }
}
